<%@page import="Demo1.Dept" %>
<%@page import="java.util.List" %>
<%@page contentType="text/html; charset=UTF-8"%>
<!<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>欢迎使用oa</title>
    <style>
        table{
            border: 2px solid orangered;
            margin:30px auto;
            border-collapse: collapse;
            text-align: center;
            height: 150px;
        }
        tr,td,th{
            border: 2px solid yellowgreen;
        }
    </style>
    <script>
        function del(dno){
            if(window.confirm('亲确定要删除吗?')){
                // 进入到删除该记录的java程序中
                window.location.href = 'http://localhost:8080/<%=request.getContextPath()%>/dept/delete?deptno='+dno;
            }
        }
    </script>
</head>
<body>
<h1><a href="http://localhost:8080<%=request.getContextPath()%>/user/exit">[退出登录]</a></h1>
<table width="50%" cellspacing="0" cellpadding="0">
    <caption>部门信息表</caption>
    <thead>
    <tr>
        <th>部门号</th>
        <th>名称</th>
        <th>工作地点</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>

    <%
        List<Dept> depts = (List<Dept>)request.getAttribute("DeptList");
        for(Dept dept:depts){
            System.out.println(dept);
    %>
    <tr>
        <td><%=dept.getDeptno()%></td>
        <td><%=dept.getDname()%></td>
        <td><%=dept.getLoc()%></td>
        <td>
            <a href="javascript:void(0);" onclick="del(<%=dept.getDeptno()%>);">删除</a>
            <a href="<%=request.getContextPath()%>/dept/detail?flag=modify&dno=<%=dept.getDeptno()%>">修改</a>
            <a href="<%=request.getContextPath()%>/dept/detail?flag=detail&dno=<%=dept.getDeptno()%>">详情</a>
        </td>
    </tr>
    <%
        }
    %>

    </tbody>
    <tfoot>
    <tr>
        <td colspan="4" style="font-size: 16px;"><a href="<%=request.getContextPath()%>/add.jsp">新增</a></td>
    </tr>
    </tfoot>
</table>
</body>
</html>